<template>
  <transition name="dialog-fade">
    <el-dialog
      v-if="showDialog"
      :title="dialogTitle"
      class="dialog-component"
      :visible.sync="showDialog"
      width="1200px"
      height="1000px"
      @close="closeDialog(0)">
      <div style="font-size: 18px">报名人数：{{ total }} 人</div>
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label-width="100px" label="用户学号" prop="userName">
          <el-input
            v-model="queryParams.userName"
            placeholder="请输入用户学号"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label-width="100px" label="用户所在班级" prop="userDept">
          <el-input
            v-model="queryParams.userDept"
            placeholder="请输入用户所在学院"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <!--增删改查操作-->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['system:sportApplyUser:export']"
          >导出
          </el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <!----------------------------表格数据-------------------------------------------------------------------->
      <el-table v-loading="loading" :data="applyUserList">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column label="用户登陆名" align="center" prop="userName"/>
        <el-table-column label="用户姓名" align="center" prop="userNickname"/>
        <el-table-column label="用户电话" align="center" prop="userPhone"/>
        <el-table-column label="学院" align="center" prop="params.dept.deptName"/>
        <el-table-column label="比赛项目名称" align="center" prop="itemName"/>
        <el-table-column label="报名时间" align="center" prop="applyTime" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.applyTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-dialog>
  </transition>
</template>


<script>
import {listSportApplyUser} from "@/api/system/sportApplyUser";

export default {
  name: "sportApplyUser",
  props: {
    dialogTitle: {
      type: String,
      default: "报名详情"
    },
    itemInfo: {
      type: Object,
      default: function () {
        return {};
      },
    },
  },

  data() {
    return {
      // 非多个禁用
      multiple: true,
      tag: false,
      loading: false,
      total: 0,
      applyUserList: [],
      showDialog: false,
      formInfo: JSON.parse(JSON.stringify(this.itemInfo)),
      // 查询参数-->
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userName: null,
        userNickname: null,
        userPhone: null,
        userDept: null,
        itemId: null,
        itemName: null,
        applyTime: null,
        score: null
      },
      // 显示搜索条件-->
      showSearch: true,
    };
  },

  created() {
    this.getList();
  },

  methods: {
    /** 导出按钮操作 */
    handleExport() {
      this.queryParams.itemId = this.formInfo.id;
      this.download('system/sportApplyUser/export', {
        ...this.queryParams
      }, `sportApplyUser_${new Date().getTime()}.xlsx`)
    },

    getList() {
      this.loading = true;
      let queryParams = {
        pageNum: 1,
        pageSize: 10,
        itemId: this.formInfo.id
      };
      listSportApplyUser(queryParams).then(response => {
        this.applyUserList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    /**
     * 关闭弹窗
     */
    closeDialog(flag) {
      this.showDialog = false;
      this.$emit("closeDialog", flag);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
}

</script>

<style scoped>
.edit-input {
}
</style>
